import java.sql.*;
import java.util.ResourceBundle;

public class Main {
    public static void main(String[] args) {
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        ResourceBundle resourceBundle = ResourceBundle.getBundle("jdbc");
        String url = resourceBundle.getString("url");
        String driver = resourceBundle.getString("driver");
        String user = resourceBundle.getString("user");
        String password = resourceBundle.getString("password");


        try {
            // 获取驱动
            Class.forName(driver);
            // 获取通道
            connection = DriverManager.getConnection(url,user,password);
            // 获取连接对象
            String sql = "select ename as name,sal as s from emp where ename = ? and sal = ? ";
            preparedStatement = connection.prepareStatement(sql);

            preparedStatement.setString(1,"king");
            preparedStatement.setInt(2,5000);

            // 执行sql语句
            resultSet = preparedStatement.executeQuery();
            int count = 0;
            if(resultSet.next())
            {
                String name = resultSet.getString("name");
                int sal = resultSet.getInt("s");
                System.out.println(name+sal);
                System.out.println(count);
            }
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}